<template>
  <div>
    <div style="display: flex;padding: 10%">
      <el-input v-model="input" placeholder="请输入文件码"></el-input>
      <el-button type="success"  @click="selected" style="margin-left: 10%">下载文件</el-button>
    </div>
  </div>
</template>

<script>
import {test } from "@/api/shareDrive/index";

export default {
  name: "index",
  data() {
    return {
      input: ''
    }
  },
  methods: {
    // 选择图标
    selected(){
      if(this.input == null || this.input.trim() == ""){
        this.$message.error('未输入任何内容');
        return
      }

      test(
        this.input
      ).then(response => {
        if(response.data.hasFile == "no"){
          this.$message.error('未能找到有效文件');
        }else{
          this.$message.success('马上开始下载');
          window.open(process.env.VUE_APP_BASE_API + "/shareDive/file/download?id=" + this.input);
        }
      })

    },
  }
}

</script>

<style scoped>
  #header{
    border-bottom: 1px solid #000000;
    padding-bottom: 10px;
  }
</style>
